unit DuplicataReceberFr;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
  ComCtrls, ExtCtrls, StdCtrls, EditBtn, Buttons, DBGrids, MainFr, DataRecord;

type

  { TDuplRecMainFrame }

  TDuplRecMainFrame = class(TMainFrame)
    DataEdit: TDateEdit;
    DBGrid1: TDBGrid;
    FiltroComboBox: TComboBox;
    ClienteEdit: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    MostrarBtn: TBitBtn;
    Panel1: TPanel;
    ToolBar1: TToolBar;
    ToolButton1: TToolButton;
    ToolButton2: TToolButton;
    ToolButton3: TToolButton;
    ToolButton4: TToolButton;
    ToolButton5: TToolButton;
    procedure DataEditChange(Sender: TObject);
    procedure FiltroComboBoxClick(Sender: TObject);
    procedure MostrarBtnClick(Sender: TObject);
    procedure SetDataRecord(Data: TDataRecord); override;
  private
    { private declarations }
  public
    { public declarations }
  end;

implementation

uses
  DuplicataReceberFrDM;

{ TDuplRecMainFrame }

procedure TDuplRecMainFrame.FiltroComboBoxClick(Sender: TObject);
begin

  //Todas as duplicatas
  if FiltroComboBox.ItemIndex = 0 then begin
    DuplicataReceberFrData.BuscaDuplicatasTodas();
  end else
  //Duplicatas Pagas
  if FiltroComboBox.ItemIndex = 1 then begin
    DuplicataReceberFrData.BuscaDuplicatasQuitadas();
  end else
  //Duplicatas a Vencer
  if FiltroComboBox.ItemIndex = 2 then begin
    DuplicataReceberFrData.BuscaDuplicatasAVencer();
  end else
  //Duplicatas Atrasadas
  if FiltroComboBox.ItemIndex = 3 then begin
    DuplicataReceberFrData.BuscaDuplicatasAtrasadas();
  end else
  //Duplicatas Canceladas
  if FiltroComboBox.ItemIndex = 4 then begin
    DuplicataReceberFrData.BuscaDuplicatasCanceladas();
  end;
end;

procedure TDuplRecMainFrame.MostrarBtnClick(Sender: TObject);
begin
  if ClienteEdit.Text <> '' then begin
    DuplicataReceberFrData.BuscarDuplicataCliente(ClienteEdit.Text);
  end;
end;

procedure TDuplRecMainFrame.SetDataRecord(Data: TDataRecord);
begin
  // Verifica se o frame possui módulo de dados
  if (MainDataModule <> nil) then
    // Atribui um DataRecord ao DataSet
    MainDataModule.SetDataRecord(Data);
end;

procedure TDuplRecMainFrame.DataEditChange(Sender: TObject);
begin
  if DataEdit.Text <> '' then begin
    DuplicataReceberFrData.BuscaDuplicataData(DataEdit.Text);
  end;
end;

initialization
  {$I duplicatareceberfr.lrs}

end.


